home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / LIB / GLUT / win32_x11.h < prev   
Encoding:
C/C++ Source or Header  |  1998-08-12  |  8.7 KB  |  320 lines

  1. #ifndef __win32_x11_h__
  2. #define __win32_x11_h__
  3.  
  4. /* Copyright (c) Nate Robins, 1997. */
  5.  
  6. /* This program is freely distributable without licensing fees 
  7.    and is provided without guarantee or warrantee expressed or 
  8.    implied. This program is -not- in the public domain. */
  9.  
  10. #include <stdlib.h>
  11. #include <windows.h>
  12.  
  13. /* Type definitions (conversions) */
  14. typedef int Visual;            /* Win32 equivalent of X11 type */
  15. typedef HWND Window;
  16. typedef HPALETTE Colormap;
  17. typedef PIXELFORMATDESCRIPTOR XVisualInfo;
  18. typedef BOOL Bool;
  19. typedef MSG XEvent;
  20. typedef HDC Display;
  21. typedef HCURSOR Cursor;
  22.  
  23. typedef int Atom;            /* dummies */
  24. typedef int XDevice;
  25. typedef int Status;
  26.  
  27. #define True  TRUE            /* Win32 equivalents of X11 booleans */
  28. #define False FALSE
  29.  
  30. #define None                 0L    /* universal null resource or null atom */
  31.  
  32. /* Input Event Masks. Used as event-mask window attribute and as arguments
  33.    to Grab requests.  Not to be confused with event names.  */
  34.  
  35. #define NoEventMask            0L
  36. #define KeyPressMask            (1L<<0)  
  37. #define KeyReleaseMask            (1L<<1)  
  38. #define ButtonPressMask            (1L<<2)  
  39. #define ButtonReleaseMask        (1L<<3)  
  40. #define EnterWindowMask            (1L<<4)  
  41. #define LeaveWindowMask            (1L<<5)  
  42. #define PointerMotionMask        (1L<<6)  
  43. #define PointerMotionHintMask        (1L<<7)  
  44. #define Button1MotionMask        (1L<<8)  
  45. #define Button2MotionMask        (1L<<9)  
  46. #define Button3MotionMask        (1L<<10) 
  47. #define Button4MotionMask        (1L<<11) 
  48. #define Button5MotionMask        (1L<<12) 
  49. #define ButtonMotionMask        (1L<<13) 
  50. #define KeymapStateMask            (1L<<14)
  51. #define ExposureMask            (1L<<15) 
  52. #define VisibilityChangeMask        (1L<<16) 
  53. #define StructureNotifyMask        (1L<<17) 
  54. #define ResizeRedirectMask        (1L<<18) 
  55. #define SubstructureNotifyMask        (1L<<19) 
  56. #define SubstructureRedirectMask    (1L<<20) 
  57. #define FocusChangeMask            (1L<<21) 
  58. #define PropertyChangeMask        (1L<<22) 
  59. #define ColormapChangeMask        (1L<<23) 
  60. #define OwnerGrabButtonMask        (1L<<24) 
  61.  
  62. /* Key masks. Used as modifiers to GrabButton and GrabKey, results of
  63.    QueryPointer, state in various key-, mouse-, and button-related
  64.    events. */
  65.  
  66. #define ShiftMask        (1<<0)
  67. #define LockMask        (1<<1)
  68. #define ControlMask        (1<<2)
  69. #define Mod1Mask        (1<<3)
  70. #define Mod2Mask        (1<<4)
  71. #define Mod3Mask        (1<<5)
  72. #define Mod4Mask        (1<<6)
  73. #define Mod5Mask        (1<<7)
  74.  
  75. /* Window classes used by CreateWindow */
  76. /* Note that CopyFromParent is already defined as 0 above */
  77.  
  78. #define InputOutput        1
  79. #define InputOnly        2
  80.  
  81. /* Window attributes for CreateWindow and ChangeWindowAttributes */
  82.  
  83. #define CWBackPixmap        (1L<<0)
  84. #define CWBackPixel        (1L<<1)
  85. #define CWBorderPixmap        (1L<<2)
  86. #define CWBorderPixel           (1L<<3)
  87. #define CWBitGravity        (1L<<4)
  88. #define CWWinGravity        (1L<<5)
  89. #define CWBackingStore          (1L<<6)
  90. #define CWBackingPlanes            (1L<<7)
  91. #define CWBackingPixel            (1L<<8)
  92. #define CWOverrideRedirect    (1L<<9)
  93. #define CWSaveUnder        (1L<<10)
  94. #define CWEventMask        (1L<<11)
  95. #define CWDontPropagate            (1L<<12)
  96. #define CWColormap        (1L<<13)
  97. #define CWCursor            (1L<<14)
  98.  
  99. /* ConfigureWindow structure */
  100.  
  101. #define CWX            (1<<0)
  102. #define CWY            (1<<1)
  103. #define CWWidth            (1<<2)
  104. #define CWHeight        (1<<3)
  105. #define CWBorderWidth        (1<<4)
  106. #define CWSibling        (1<<5)
  107. #define CWStackMode        (1<<6)
  108.  
  109.  
  110. /* Used in GetWindowAttributes reply */
  111.  
  112. #define IsUnmapped        0
  113. #define IsUnviewable        1
  114. #define IsViewable        2
  115.  
  116. /* Window stacking method (in configureWindow) */
  117.  
  118. #define Above                   0
  119. #define Below                   1
  120. #define TopIf                   2
  121. #define BottomIf                3
  122. #define Opposite                4
  123.  
  124. /* For CreateColormap */
  125.  
  126. #define AllocNone        0    /* create map with no entries */
  127. #define AllocAll        1    /* allocate entire map writeable */
  128.  
  129.  
  130. /* Flags used in StoreNamedColor, StoreColors */
  131.  
  132. #define DoRed            (1<<0)
  133. #define DoGreen            (1<<1)
  134. #define DoBlue            (1<<2)
  135.  
  136. /* 
  137.  * Bitmask returned by XParseGeometry().  Each bit tells if the corresponding
  138.  * value (x, y, width, height) was found in the parsed string.
  139.  */
  140. #define NoValue        0x0000
  141. #define XValue      0x0001
  142. #define YValue        0x0002
  143. #define WidthValue      0x0004
  144. #define HeightValue      0x0008
  145. #define AllValues     0x000F
  146. #define XNegative     0x0010
  147. #define YNegative     0x0020
  148.  
  149. /* flags argument in size hints */
  150. #define USPosition    (1L << 0) /* user specified x, y */
  151. #define USSize        (1L << 1) /* user specified width, height */
  152.  
  153. /* definitions for initial window state */
  154. #define WithdrawnState 0    /* for windows that are not mapped */
  155. #define NormalState 1    /* most applications want to start this way */
  156. #define IconicState 3    /* application wants to start as an icon */
  157. #define GameModeState 4  /* Win32 GLUT only (not in Xlib!). */
  158.  
  159. /* Type definitions */
  160.  
  161. typedef struct {
  162.     unsigned int background_pixmap;    /* background pixmap */
  163.     unsigned long background_pixel;    /* background pixel */
  164.     unsigned long border_pixel;    /* border pixel value */
  165.     long event_mask;        /* set of events that should be saved */
  166.     long do_not_propagate_mask;    /* set of events that should not propagate */
  167.     Bool override_redirect;       /* boolean value for override-redirect */
  168.     Colormap colormap;           /* color map to be associated with window */
  169. } XSetWindowAttributes;
  170.  
  171. typedef struct {
  172.   unsigned long pixel;
  173.   unsigned short red, green, blue;
  174.   char flags;  /* do_red, do_green, do_blue */
  175. } XColor;
  176.  
  177. typedef struct {
  178.   unsigned char *value;       /* same as Property routines */
  179.   Atom encoding;       /* prop type */
  180.   int format;           /* prop data format: 8, 16, or 32 */
  181.   unsigned long nitems;       /* number of data items in value */
  182. } XTextProperty;
  183.  
  184. typedef struct {
  185.   long flags;            /* marks which fields in this structure are defined */
  186.   int x, y;        /* obsolete for new window mgrs, but clients */
  187.   int width, height;    /* should set so old wm's don't mess up */
  188. } XSizeHints;
  189.  
  190. /* Functions emulated by macros. */
  191.  
  192. #define XFreeColormap(display, colormap) \
  193.   DeleteObject(colormap)
  194.  
  195. #define XCreateFontCursor(display, shape) \
  196.   LoadCursor(NULL, shape)
  197.  
  198. #define XDefineCursor(display, window, cursor) \
  199.   SetCursor(cursor)
  200.  
  201. #define XFlush(display) \
  202.   /* Nothing. */
  203.  
  204. #define DisplayWidth(display, screen) \
  205.   GetSystemMetrics(SM_CXSCREEN)
  206.  
  207. #define DisplayHeight(display, screen) \
  208.   GetSystemMetrics(SM_CYSCREEN)
  209.  
  210. #define XMapWindow(display, window) \
  211.   ShowWindow(window, SW_SHOWNORMAL)
  212.  
  213. #define XUnmapWindow(display, window) \
  214.   ShowWindow(window, SW_HIDE)
  215.  
  216. #define XIconifyWindow(display, window, screen) \
  217.   ShowWindow(window, SW_MINIMIZE)
  218.  
  219. #define XWithdrawWindow(display, window, screen) \
  220.   ShowWindow(window, SW_HIDE)
  221.  
  222. #define XLowerWindow(display, window) \
  223.   SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
  224.  
  225. #define XSetWMName(display, window, tp) \
  226.   SetWindowText(window, (tp)->value)
  227.  
  228. /* There really isn't a way to set the icon name separate from the
  229.    windows name in Win32, so, just set the windows name. */
  230. #define XSetWMIconName(display, window, tp) \
  231.   XSetWMName(display, window, tp)
  232.  
  233. #define XDestroyWindow(display, window) \
  234.   DestroyWindow(window)
  235.  
  236. /* Anything that needs to be freed was allocated with malloc in our
  237.    fake X windows library for Win32, so free it with plain old
  238.    free(). */
  239. #define XFree(data) \
  240.   free(data)
  241.  
  242. /* Nothing to be done for this...the pointer is always 'ungrabbed'
  243.    in Win32. */
  244. #define XUngrabPointer(display, time) \
  245.   /* Nothing. */
  246.  
  247. /* Function prototypes. */
  248.  
  249. extern XVisualInfo* XGetVisualInfo(
  250.   Display* display,
  251.   long mask,
  252.   XVisualInfo* ttemplate,  /* Avoid class with C++ keyword. */
  253.   int*nitems);
  254.  
  255. extern Colormap XCreateColormap(
  256.   Display* display,
  257.   Window root,
  258.   Visual* visual,
  259.   int alloc);
  260.  
  261. extern void XAllocColorCells(
  262.   Display* display,
  263.   Colormap colormap,
  264.   Bool contig, 
  265.   unsigned long plane_masks_return[],
  266.   unsigned int nplanes,
  267.   unsigned long pixels_return[],
  268.   unsigned int npixels);
  269.  
  270. extern void XStoreColor(
  271.   Display* display,
  272.   Colormap colormap,
  273.   XColor* color);
  274.  
  275. extern void XSetWindowColormap(
  276.   Display* display,
  277.   Window window,
  278.   Colormap colormap);
  279.  
  280. extern Bool XTranslateCoordinates(
  281.   Display *display,
  282.   Window src, Window dst, 
  283.   int src_x, int src_y, 
  284.   int* dest_x_return, int* dest_y_return,
  285.   Window* child_return);
  286.  
  287. extern Status XGetGeometry(
  288.   Display* display,
  289.   Window window,
  290.   Window* root_return, 
  291.   int* x_return, int* y_return, 
  292.   unsigned int* width_return, unsigned int* height_return,
  293.   unsigned int *border_width_return,
  294.   unsigned int* depth_return);
  295.  
  296. extern int DisplayWidthMM(
  297.   Display* display,
  298.   int screen);
  299.  
  300. extern int DisplayHeightMM(
  301.   Display* display,
  302.   int screen);
  303.  
  304. extern void XWarpPointer(
  305.   Display* display,
  306.   Window src, Window dst, 
  307.   int src_x, int src_y,
  308.   int src_width, int src_height, 
  309.   int dst_x, int dst_y);
  310.  
  311. extern int XParseGeometry(
  312.   char* string,
  313.   int* x, int* y, 
  314.   unsigned int* width, unsigned int* height);
  315.  
  316. extern int XPending(
  317.   Display* display);
  318.  
  319. #endif /* __win32_x11_h__ */
  320.